package com.share.rule.api;

import com.share.api.rule.domain.FeeRule;

import com.share.api.rule.domain.FeeRuleRequestForm;
import com.share.api.rule.domain.FeeRuleResponseVo;
import com.share.common.core.domain.R;



import com.share.rule.service.IFeeRuleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/feeRuleApi")
public class FeeRuleApiController {


    @Autowired
    private IFeeRuleService feeRuleService;


    /**
     * 获取费用规则详细信息
     */
    @Operation(summary = "获取费用规则详细信息")
    @GetMapping(value = "/getFeeRule/{id}")
    public R<FeeRule> getFeeRule(@PathVariable("id") Long id) {
        FeeRule feeRule = feeRuleService.getById(id);
        return R.ok(feeRule);
    }

    /*
    * 批量获取规则数据列表
    * */
    @Operation(summary = "批量获取规则数据列表")
    @PostMapping(value = "/getFeeRuleList")
    public R<List<FeeRule>> getFeeRuleList(@RequestBody List<Long> FeeRuleIds) {
        List<FeeRule> feeRuleList = feeRuleService.listByIds(FeeRuleIds);
        return R.ok(feeRuleList);
    }


    /**
     * 订单费用计算
     */
    @PostMapping("/calculateOrderFee")
    public R<FeeRuleResponseVo> calculateOrderFee(@RequestBody FeeRuleRequestForm ruleRequestForm) {
        FeeRuleResponseVo feeRuleResponseVo = feeRuleService.calculateOrderFee(ruleRequestForm);
        return R.ok(feeRuleResponseVo);
    }

}
